package la.bbs558.entity.enums;

import lombok.Getter;

import java.util.Optional;

@Getter
public enum UserState {
    TRUE(1,"正常"),
    FALSE(0,"禁用");

    private final Integer code;
    private final String desc;

    UserState(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static Optional<UserState> getByCode(Integer code) {
        for (UserState userState : UserState.values()) {
            if (userState.getCode().equals(code)) {
                return Optional.of(userState);
            }
        }
        return Optional.empty();
    }
}
